﻿using System;
using System.Collections.Generic;
using System.Text;
using EmbeddedSharp.Core;

namespace EmbeddedSharp.Scripting.Function.Settings {
    public class ApplicationSettingsNode : FuncNode {

        public ApplicationSettingsNode()
            : base() {
            base.Value = "ApplicationSettings";
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                return new ArgumentException(
                    "Usage: ApplicationSettings(settingName);");
            }

            string arg = Convert.ToString(Parameters[0].Evaluate());
            switch (arg) {
                case "UserName":
                    return Environment.UserName;
                    break;
                case "OSVersion":
                    return Environment.OSVersion;
                    break;
                case "Version":
                    return Environment.Version;
                    break;
                case "DomainName":
                    return Environment.UserDomainName;
                    break;
                case "CurrentDirectory":
                    return Environment.CurrentDirectory;
                    break;
                case "CommandLine":
                    return Environment.CommandLine;
                    break;
                case "SystemDirectory":
                    return Environment.SystemDirectory;
                    break;
                case "ProcessorCount":
                    return Environment.ProcessorCount;
                    break;
                case "MachineName":
                    return Environment.MachineName;
                    break;
                default:
                    break;
            }

            return string.Empty;
        }
    }
}
